home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / ShapeShifter / VideoDrivers / SD64evd / SD64evd_TEST.asm < prev    next >
Assembly Source File  |  1996-06-01  |  8KB  |  470 lines

  1. *
  2. * SD64evd_TEST.asm - ShapeShifter external video driver for PiccoloSD64
  3. *                    *********** ONLY FOR TESTING PURPOSE *************
  4. *
  5. * $VER: SD64evd_TEST.asm 1.0 (20.05.96)
  6. *
  7. * By Francesco Doro (fdoro@gpnet.it)
  8. *
  9.  
  10.     incdir    "INCLUDE_I:"
  11.         
  12.     INCLUDE    "exec/types.i"
  13.     INCLUDE    "exec/macros.i"
  14.     INCLUDE    "exec/memory.i"
  15.     INCLUDE    "intuition/intuition.i"
  16.     INCLUDE    "utility/tagitem.i"
  17.     INCLUDE    "exec/alerts.i"
  18.     INCLUDE    "shapeextvideo.i"
  19.  
  20. *
  21. * Definition of our private context structure for storing local variables
  22. *
  23.  
  24.  STRUCTURE    MyContext,0
  25.     APTR    conIntBase
  26.     APTR    conGfxBase
  27.     APTR    conDOSBase
  28.     APTR    conExpBase
  29.  
  30.     APTR    conScreen    ;The screen
  31.     APTR    conViewPort    ;The screen's ViewPort
  32.     APTR    conBitMap    ;The screen's RastPort
  33.  
  34.     LONG    conBytesPerRow
  35.     APTR    conDisplayMem    ;Display base in SD64 memory
  36.     APTR    conSD64reg    ;Base of SD64 registers
  37.  
  38.     WORD    conVideoMode    ;Video mode (VMODE_*)
  39.  
  40.  LABEL    MyContext_SIZEOF
  41.  
  42. *
  43. * This is the driver header
  44. *
  45.  
  46.         EVHEADER DriverTags
  47.  
  48. *
  49. * The header tags that describe the driver and provide pointers to
  50. * the driver's routines
  51. *
  52.  
  53. DriverTags    dc.l    SHEV_Level,1        ;Interface level 1
  54.         dc.l    SHEV_Version,1
  55.         dc.l    SHEV_Revision,0
  56.         dc.l    SHEV_Name,DriverName
  57.         dc.l    SHEV_ID,DriverID
  58.         dc.l    SHEV_Author,DriverAuthor
  59.  
  60.         dc.l    SHEV_OpenScreen,MyOpenScreen
  61.         dc.l    SHEV_CloseScreen,MyCloseScreen
  62.         dc.l    TAG_END,0
  63.  
  64. DriverName    dc.b    "PiccoloSD64 TEST 24 bit Driver",0
  65.         CNOP    0,4
  66. DriverID    dc.b    '$VER: SD64evd_TEST 1.0'
  67.         dc.b    ' by Francesco Doro (20.05.96)',13,10,0
  68.         CNOP    0,4
  69. DriverAuthor    dc.b    "Francesco Doro (fdoro@gpnet.it)",0
  70.         CNOP    0,4
  71.  
  72.  
  73. *
  74. * The OpenScreen routine
  75. * a0: Taglist with input parameters
  76. * a1: Taglist with output parameters
  77. * a6: Base of utility.library
  78. *
  79.  
  80. MyOpenScreen    movem.l    d2-d7/a2-a6,-(sp)
  81.         move.l    a0,a4            ;a4: Input taglist
  82.         move.l    a1,a5            ;a5: Output taglist
  83.         move.l    a6,d7            ;d7: UtilityBase
  84.  
  85.  
  86. ; Allocate memory for context
  87.  
  88.         move.l    4,a6
  89.         move.l    #MyContext_SIZEOF,d0
  90.         move.l    #$00010001,d1
  91.         jsr    -684(a6)        :AllocVec
  92.         tst.l    d0
  93.         beq    OpenFailed1
  94.         move.l    d0,a2            ;a2: Context
  95.  
  96.  
  97. ; Open intuition.library
  98.  
  99.         move.l    4,a6
  100.         lea    IntName(pc),a1
  101.         moveq    #37,d0
  102.         jsr    -552(a6)        ;OpenLibrary
  103.         move.l    d0,conIntBase(a2)
  104.         beq    OpenFailed2
  105.  
  106.  
  107. ; Open graphics.library
  108.  
  109.         move.l    4,a6
  110.         lea    GfxName(pc),a1
  111.         moveq    #37,d0
  112.         jsr    -552(a6)        ;OpenLibrary
  113.         move.l    d0,conGfxBase(a2)
  114.         beq    OpenFailed3
  115.  
  116.  
  117. ; Open dos.library
  118.  
  119.         move.l    4,a6
  120.         lea    DOSName(pc),a1
  121.         moveq    #37,d0
  122.         jsr    -552(a6)        ;OpenLibrary
  123.         move.l    d0,conDOSBase(a2)
  124.         beq    OpenFailed4
  125.  
  126.  
  127. ; Open expansion.library
  128.  
  129.         move.l    4,a6
  130.         lea    ExpName(pc),a1
  131.         moveq    #0,d0
  132.         jsr    -552(a6)        ;OpenLibrary
  133.         move.l    d0,conExpBase(a2)
  134.         beq    OpenFailed12
  135.  
  136.  
  137. ; Check board and get video memory address
  138.  
  139.         move.l    conExpBase(a2),a6
  140.         suba.l    a0,a0
  141.         move.l    #$893,d0
  142.         moveq    #10,d1
  143.         jsr    -72(a6)            ;FindConfigDev
  144.         tst.l    d0
  145.         beq    OpenFailed13
  146.         move.l    d0,a0
  147.         move.l    $20(a0),d0
  148.         move.l    d0,conDisplayMem(a2)
  149.         beq    OpenFailed13
  150.  
  151.         move.l    conExpBase(a2),a6
  152.         suba.l    a0,a0
  153.         move.l    #$893,d0
  154.         moveq    #11,d1
  155.         jsr    -72(a6)            ;FindConfigDev
  156.         tst.l    d0
  157.         beq    OpenFailed13
  158.         move.l    d0,a0
  159.         move.l    $20(a0),d0
  160.         move.l    d0,conSD64reg(a2)
  161.         beq    OpenFailed13
  162.  
  163.  
  164.  
  165. ; Store context pointer in output taglist
  166.  
  167.         move.l    d7,a6
  168.         move.l    a5,a0
  169.         move.l    #SHEV_Context,d0
  170.         jsr    -30(a6)        ;FindTagItem
  171.         move.l    d0,a0
  172.         move.l    a2,ti_Data(a0)
  173.  
  174.  
  175.  
  176. ; Get video mode and set the refresh type and screen depth accordingly
  177.  
  178.         move.l    d7,a6
  179.         move.l    a4,a0
  180.         move.l    #SHEV_VideoMode,d0
  181.         jsr    -36(a6)        ;GetTagData
  182.         move.w    d0,conVideoMode(a2)
  183.         cmp.l    #VMODE_24BIT,d0
  184.         bne    OpenFailed5
  185.         move.l    a5,a0
  186.         move.l    #SHEV_RefreshType,d0
  187.         jsr    -30(a6)        ;FindTagItem
  188.         tst.l    d0
  189.         beq    OpenFailed6
  190.         move.l    d0,a1
  191.         move.l    #RTYPE_NONE,ti_Data(a1)    ;no refresh
  192.         move.l    #24,ScrDepth
  193.  
  194.  
  195. ; Extract screen parameters from input taglist
  196.  
  197.         move.l    d7,a6
  198.         move.l    a4,a0
  199.         move.l    #SHEV_ScreenX,d0
  200.         moveq    #0,d1
  201.         jsr    -36(a6)        ;GetTagData
  202.         move.l    d0,ScrWidth
  203.         lsl.l    #2,d0
  204.         move.l    d0,conBytesPerRow(a2)
  205.  
  206.         move.l    a4,a0
  207.         move.l    #SHEV_ScreenY,d0
  208.         moveq    #0,d1
  209.         jsr    -36(a6)        ;GetTagData
  210.         move.l    d0,ScrHeight
  211.  
  212.         move.l    a4,a0
  213.         move.l    #SHEV_DisplayID,d0
  214.         moveq    #0,d1
  215.         jsr    -36(a6)        ;GetTagData
  216.         move.l    d0,ScrDisplayID
  217.  
  218.         move.l    a4,a0
  219.         move.l    #SHEV_OverscanType,d0
  220.         moveq    #OSCAN_TEXT,d1
  221.         jsr    -36(a6)        ;GetTagData
  222.         move.l    d0,ScrOverscan
  223.  
  224.  
  225. ; Open the screen and store pointer in output taglist
  226.  
  227.         move.l    conIntBase(a2),a6
  228.         sub.l    a0,a0
  229.         lea    ScreenTags,a1
  230.         jsr    -612(a6)    ;OpenScreenTagList
  231.         move.l    d0,a3        ;a3: Screen
  232.         move.l    d0,conScreen(a2)
  233.         beq    OpenFailed9
  234.  
  235. ScreenOpened    move.l    d7,a6
  236.         move.l    a5,a0
  237.         move.l    #SHEV_Screen,d0
  238.         jsr    -30(a6)        ;FindTagItem
  239.         move.l    d0,a0
  240.         move.l    a3,ti_Data(a0)
  241.  
  242.  
  243. ; Extract our private data
  244.  
  245.         lea    sc_ViewPort(a3),a0
  246.         move.l    a0,conViewPort(a2)
  247.         lea    sc_RastPort(a3),a0
  248.         move.l    rp_BitMap(a0),conBitMap(a2)
  249.  
  250.  
  251. ; Extract all the other data that the caller wants
  252.  
  253.         move.l    d7,a6
  254.         move.l    a5,a0
  255.         move.l    #SHEV_ScreenBase,d0
  256.         jsr    -30(a6)        ;FindTagItem
  257.         tst.l    d0
  258.         beq    OpenFailed10
  259.         move.l    d0,a1
  260.         move.l    conDisplayMem(a2),ti_Data(a1)
  261.  
  262.         move.l    d7,a6
  263.         move.l    a5,a0
  264.         move.l    #SHEV_BytesPerRow,d0
  265.         jsr    -30(a6)        ;FindTagItem
  266.         tst.l    d0
  267.         beq    OpenFailed11
  268.         move.l    d0,a1
  269.         move.l    conBytesPerRow(a2),ti_Data(a1)
  270.  
  271.  
  272. ; Everything is OK
  273.  
  274.         movem.l    (sp)+,d2-d7/a2-a6
  275.         moveq    #0,d0
  276.         rts
  277.  
  278. ; An error occurred
  279.  
  280. OpenFailed    movem.l    (sp)+,d2-d7/a2-a6
  281.         moveq    #-1,d0
  282.         rts
  283.  
  284. OpenFailed1
  285.         bra.s    OpenFailed
  286.  
  287. OpenFailed2
  288.         bra.s    OpenFailed
  289.  
  290. OpenFailed3
  291.         bra.s    OpenFailed
  292.  
  293. OpenFailed4
  294.         bra.s    OpenFailed
  295.  
  296. OpenFailed5
  297.         lea    err5(pc),a0
  298.         bra.s    doerr
  299.  
  300. OpenFailed6
  301.         lea    err6(pc),a0
  302.         bra.s    doerr
  303.  
  304. OpenFailed7
  305.         lea    err7(pc),a0
  306.         bra.s    doerr
  307.  
  308. OpenFailed9
  309.         lea    err9(pc),a0
  310.         bra.s    doerr
  311.  
  312. OpenFailed10
  313.         lea    err10(pc),a0
  314.         bra.s    doerr
  315.  
  316. OpenFailed11
  317.         lea    err11(pc),a0
  318.         bra.s    doerr
  319.  
  320. OpenFailed12
  321.         lea    err12(pc),a0
  322.         bra.s    doerr
  323.  
  324. OpenFailed13
  325.         lea    err13(pc),a0
  326.         bra.s    doerr
  327.  
  328.  
  329. ; Show error message
  330.  
  331.         nop
  332. doerr        bsr.s    doreq
  333.         bra    OpenFailed
  334.  
  335. doreq        movem.l    d0-a6,-(a7)
  336.         move.l    conIntBase(a2),a6
  337.         lea    easyreq(pc),a1
  338.         move.l    a0,es_TextFormat(a1)
  339.         suba.l    a0,a0
  340.         suba.l    a2,a2
  341.         suba.l    a3,a3
  342.         jsr    -588(a6)    ;EasyRequestArgs
  343.         movem.l    (a7)+,d0-a6
  344.         rts
  345.  
  346.  
  347. *
  348. * The CloseScreen routine
  349. * a0: Taglist with input parameters
  350. * a1: Taglist with output parameters
  351. * a2: Context pointer (never NULL)
  352. * a6: Base of utility.library
  353. *
  354.  
  355. MyCloseScreen
  356.         movem.l    d2-d7/a2-a6,-(sp)
  357.  
  358. ; Close the screen
  359.  
  360.         move.l    conScreen(a2),d0
  361.         beq.s    NoScreen
  362.         move.l    d0,a0
  363.         move.l    conIntBase(a2),a6
  364.         jsr    -66(a6)        ;CloseScreen
  365. NoScreen
  366.  
  367.  
  368. ; Close dos.library
  369.         move.l    conDOSBase(a2),d0
  370.         beq.s    nodos
  371.         move.l    d0,a1
  372.         move.l    4,a6
  373.         jsr    -414(a6)    ;CloseLibrary
  374. nodos
  375.  
  376. ; Close graphics.library
  377.         move.l    conGfxBase(a2),d0
  378.         beq.s    nogfx
  379.         move.l    d0,a1
  380.         move.l    4,a6
  381.         jsr    -414(a6)    ;CloseLibrary
  382. nogfx
  383.  
  384. ; Close intuition.library
  385.         move.l    conIntBase(a2),d0
  386.         beq.s    noint
  387.         move.l    d0,a1
  388.         move.l    4,a6
  389.         jsr    -414(a6)    ;CloseLibrary
  390. noint
  391.  
  392. ; Close expansion.library
  393.         move.l    conExpBase(a2),d0
  394.         beq.s    noexp
  395.         move.l    d0,a1
  396.         move.l    4,a6
  397.         jsr    -414(a6)    ;CloseLibrary
  398. noexp
  399.  
  400. ; Free context
  401.         move.l    4,a6
  402.         move.l    a2,a1
  403.         jsr    -690(a6)    ;FreeVec
  404.  
  405. CloseDone    movem.l    (sp)+,d2-d7/a2-a6
  406.         moveq    #0,d0
  407.         rts
  408.  
  409.  
  410. ; Library names
  411.  
  412. UtilityName    dc.b    "utility.library",0
  413. IntName        dc.b    "intuition.library",0
  414. GfxName        dc.b    "graphics.library",0
  415. DOSName        dc.b    "dos.library",0
  416. ExpName        dc.b    "expansion.library",0
  417.  
  418. ; The name of our screen
  419.  
  420. ScreenName    dc.b    "ShapeShifter Screen",0
  421.         CNOP    0,4
  422.  
  423. ; Taglist for OpenScreen()
  424.  
  425. ScreenTags    dc.l    SA_Depth
  426. ScrDepth    dc.l    0
  427.         dc.l    SA_Width
  428. ScrWidth    dc.l    0
  429.         dc.l    SA_Height
  430. ScrHeight    dc.l    0
  431.         dc.l    SA_DisplayID
  432. ScrDisplayID    dc.l    0
  433.         dc.l    SA_Overscan
  434. ScrOverscan    dc.l    0
  435.         dc.l    SA_Quiet,-1
  436.         dc.l    SA_Exclusive,-1
  437.         dc.l    SA_Title,ScreenName
  438.         dc.l    TAG_END,0
  439.  
  440.  
  441. ; Bad news...
  442.  
  443. easyreq        dc.l    EasyStruct_SIZEOF
  444.         dc.l    0
  445.         dc.l    er1
  446.         dc.l    0
  447.         dc.l    er2
  448.  
  449. er1        dc.b    "SD64evd_TEST Problem:",0
  450. er2        dc.b    "Bye!",0
  451.  
  452. err1
  453. err2
  454. err3
  455. err4
  456. err5        dc.b    "You must set color depth 24 bit",0
  457. err6        dc.b    "Can't find TagItem RefreshType",0
  458. err7
  459. err8
  460. err9        dc.b    "OpenScreen failed",0
  461. err10        dc.b    "Can't find TagItem ScreenBase",0
  462. err11        dc.b    "Can't find TagItem BytesPerRow",0
  463. err12        dc.b    "Can't open expansion.library",$a
  464.         dc.b    "Are you sure you are using an Amiga?",0
  465. err13        dc.b    "You don't have a PiccoloSD64",$a
  466.         dc.b    "or your board has some problems",0
  467.  
  468.  
  469.         END
  470.